.TH std::experimental::filesystem::path::operator= 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::filesystem::path::operator= \- std::experimental::filesystem::path::operator=

.SH Synopsis
   path& operator=( const path& p );        \fB(1)\fP (filesystem TS)
   path& operator=( path&& p );             \fB(2)\fP (filesystem TS)
   template< class Source >                 \fB(3)\fP (filesystem TS)
   path& operator=( const Source& source );

   1) Replaces the contents of *this with a copy of the contents of p.
   2) Replaces the contents of *this with p, possibly using move semantics: p is left
   in valid, but unspecified state.
   3) Replaces the contents of *this with a new path value constructed from source as
   if by overload \fB(4)\fP of the path constructor. Equivalent to assign(source).

.SH Parameters

   p      - a path to assign
            a std::basic_string, pointer to a null-terminated character/wide character
   source - string, or an input iterator that points to a null-terminated
            character/wide character sequence. The character type must be one of char,
            char16_t, char32_t, wchar_t

.SH Return value

   *this

.SH Exceptions

   1) \fI(none)\fP
   2)
   noexcept specification:
   noexcept

   3) \fI(none)\fP

.SH Example


// Run this code

 #include <experimental/filesystem>
 namespace fs = std::experimental::filesystem;

 int main()
 {
     fs::path p = "C:/users/abcdef/AppData/Local";
     p = p / "Temp"; // move assignment
     const wchar_t* wstr = L"D:/猫.txt";
     p = wstr; // assignment from a source
 }

.SH See also

   assign        assigns contents
                 \fI(public member function)\fP
   constructor   constructs a path
                 \fI(public member function)\fP

.SH Categories:
     * Noindexed pages
     * unconditionally noexcept
.SH Hidden categories:
     * Pages with unreviewed unconditional noexcept template
     * Pages with unreviewed noexcept template
